<?xml version="1.0" encoding="ISO-8859-1"?>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jstl/core"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      xmlns:t="http://myfaces.apache.org/tomahawk"
      xmlns:a="http://www.andromda.org/cartridges/jsf"
      xmlns:tr="http://myfaces.apache.org/trinidad"
      xmlns:ajsfc="http://www.andromda.org/cartridges/jsf/facelets"
      >

<ui:composition template="/layout/layout.xhtml">
    <ui:param name="partialTriggers" value="#{fn:split(':manageIndividualForm_search:newAction :manageIndividualForm_search:searchResult:loadAction :manageIndividualForm_edit:saveAction :manageIndividualForm_edit:saveAndNewAction :manageIndividualForm_edit:cancelAction',' ')}"/>
    <ui:param name="usesUpload" value="false"/>
    <ui:define name="title">
        <c:set var="title" value="#{messages['individual.view.title']}#{messages['title.action.separator']}#{messages[manageIndividualForm.editState ? (empty manageIndividualForm.id ? 'title.action.new' : 'title.action.edit') : 'title.action.search']}" scope="request"/>
    </ui:define>
    <ui:define name="content">
        <tr:panelGroupLayout layout="vertical" inlineStyle="display:#{manageIndividualForm.editState?'none':''}">
        <tr:subform id="manageIndividualForm_search">
        <tr:panelFormLayout>
        <tr:inputText id="searchForm_individualId" value="#{manageIndividualForm.searchForm.individualId}" label="#{messages['individual.individual.id']}:" required="false" readOnly="false">
        </tr:inputText>
        <tr:inputText id="searchForm_idNumber" value="#{manageIndividualForm.searchForm.idNumber}" label="#{messages['individual.id.number']}:" required="false" readOnly="false">
        </tr:inputText>
        <tr:selectOneChoice id="searchForm_salutation" value="#{manageIndividualForm.searchForm.salutation}" label="#{messages['individual.salutation']}:" required="false" readOnly="false" unselectedLabel="">
            <f:converter converterId="com.systemsjr.jrbase.individual.Salutation"/>
            <f:selectItems value="#{ajsfc:getEnumSelectItems('salutation.','com.systemsjr.jrbase.individual.Salutation')}"/>
        </tr:selectOneChoice>
        <tr:inputText id="searchForm_surname" value="#{manageIndividualForm.searchForm.surname}" label="#{messages['individual.surname']}:" required="false" readOnly="false">
        </tr:inputText>
        <tr:inputText id="searchForm_firstName" value="#{manageIndividualForm.searchForm.firstName}" label="#{messages['individual.first.name']}:" required="false" readOnly="false">
        </tr:inputText>
        <tr:inputText id="searchForm_middleNames" value="#{manageIndividualForm.searchForm.middleNames}" label="#{messages['individual.middle.names']}:" required="false" readOnly="false">
        </tr:inputText>
        <tr:selectOneChoice id="searchForm_sex" value="#{manageIndividualForm.searchForm.sex}" label="#{messages['individual.sex']}:" required="false" readOnly="false" unselectedLabel="">
            <f:converter converterId="com.systemsjr.jrbase.individual.Gender"/>
            <f:selectItems value="#{ajsfc:getEnumSelectItems('gender.','com.systemsjr.jrbase.individual.Gender')}"/>
        </tr:selectOneChoice>
        <tr:inputText id="searchForm_postalAddress" value="#{manageIndividualForm.searchForm.postalAddress}" label="#{messages['individual.postal.address']}:" required="false" readOnly="false">
        </tr:inputText>
        <tr:inputText id="searchForm_physicalAddress" value="#{manageIndividualForm.searchForm.physicalAddress}" label="#{messages['individual.physical.address']}:" required="false" readOnly="false">
        </tr:inputText>
        <tr:inputText id="searchForm_email" value="#{manageIndividualForm.searchForm.email}" label="#{messages['individual.email']}:" required="false" readOnly="false">
        </tr:inputText>
        <tr:inputDate id="searchForm_dob" value="#{manageIndividualForm.searchForm.dob}" label="#{messages['individual.dob']}:" required="false">
            <f:convertDateTime pattern="MM/dd/yyyy"/>
        </tr:inputDate>
        <tr:selectOneChoice id="searchForm_idType" value="#{manageIndividualForm.searchForm.idType}" label="#{messages['individual.id.type']}:" required="false" readOnly="false" unselectedLabel="">
            <f:converter converterId="com.systemsjr.jrbase.individual.IDType"/>
            <f:selectItems value="#{ajsfc:getEnumSelectItems('idtype.','com.systemsjr.jrbase.individual.IDType')}"/>
        </tr:selectOneChoice>
        <tr:selectOneChoice id="searchForm_countryOfBirth" value="#{manageIndividualForm.searchForm.countryOfBirth}" label="#{messages['individual.country.of.birth']}:" required="false" readOnly="false" unselectedLabel="">
            <c:if test="${!empty manageIndividualForm.countryOfBirthBackingList}">
                <c:forEach var="row" items="#{manageIndividualForm.countryOfBirthBackingList}">
                    <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                </c:forEach>
            </c:if>
        </tr:selectOneChoice>
        <tr:selectOneChoice id="searchForm_countryOfCitizenship" value="#{manageIndividualForm.searchForm.countryOfCitizenship}" label="#{messages['individual.country.of.citizenship']}:" required="false" readOnly="false" unselectedLabel="">
            <c:if test="${!empty manageIndividualForm.countryOfCitizenshipBackingList}">
                <c:forEach var="row" items="#{manageIndividualForm.countryOfCitizenshipBackingList}">
                    <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                </c:forEach>
            </c:if>
        </tr:selectOneChoice>
        <tr:selectManyListbox id="searchForm_nextOfKins" value="#{manageIndividualForm.searchForm.nextOfKins}" label="#{messages['individual.next.of.kins']}:" required="false" readOnly="false" size="3">
            <c:if test="${!empty manageIndividualForm.nextOfKinsBackingList}">
                <c:forEach var="row" items="#{manageIndividualForm.nextOfKinsBackingList}">
                    <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                </c:forEach>
            </c:if>
        </tr:selectManyListbox>
        <f:facet name="footer">
            <tr:panelButtonBar>
                <tr:commandButton id="searchAction" text="#{messages['action.search']}" action="#{individualController.search}" accessKey="#{messages['action.search.access.key']}" partialSubmit="true"/>
                <tr:commandButton id="newAction" text="#{messages['action.new']}" action="#{individualController.startNew}" accessKey="#{messages['action.new.access.key']}" partialSubmit="true" immediate="true"/>
            </tr:panelButtonBar>
        </f:facet>
        </tr:panelFormLayout>
        <tr:spacer width="1" height="10"/>
        <tr:table id="searchResult" allDetailsEnabled="true" var="row" rowBandingInterval="1" value="#{manageIndividualForm.manageableList}" rows="#{preferences.maxTableRows}" width="90%" inlineStyle="display:#{manageIndividualForm.manageableList == null? 'none': ''}" partialTriggers="searchResult:deleteAction ::searchAction">
            <f:facet name="footer">
                <h:panelGroup>
                    <tr:outputText value="#{fn:length(manageIndividualForm.manageableList)}">
                        <f:convertNumber groupingUsed="true"/>
                    </tr:outputText>
                    <tr:spacer width="10" height="1"/>
                    <tr:outputText value="#{messages['records.found']}"/>
                </h:panelGroup>
                <h:panelGroup style="width:100%;font-weight:normal">
                    <tr:outputText value="#{fn:length(manageIndividualForm.manageableList)}" inlineStyle="display:#{empty manageIndividualForm.manageableList?'none':''}">
                        <f:convertNumber groupingUsed="true"/>
                    </tr:outputText>
                    <tr:spacer width="10" height="1" inlineStyle="display:#{empty manageIndividualForm.manageableList?'none':''}"/>
                    <tr:outputText value="#{messages['records.found']}" inlineStyle="display:#{empty manageIndividualForm.manageableList?'none':''}"/>
                    <tr:outputText value="#{messages['empty.result.set']}" inlineStyle="display:#{empty manageIndividualForm.manageableList?'':'none'}"/>
                </h:panelGroup>
            </f:facet>
            <tr:column width="46px">
                <f:facet name="header">
                    <h:panelGroup>
                        <tr:commandLink action="#{individualController.odsExport}" inlineStyle="display:#{empty manageIndividualForm.manageableList?'none':''}">
                            <tr:image source="/images/spreadsheet.png" shortDesc="#{messages['export.spreadsheet']}" inlineStyle="border-style:none" />
                        </tr:commandLink>
                    </h:panelGroup>
                </f:facet>
                <h:panelGroup>
                    <tr:commandLink id="loadAction" actionListener="#{individualController.load}" partialSubmit="true" immediate="true">
                       <tr:image source="/images/tableLoad.gif" shortDesc="#{messages['action.load']}" inlineStyle="border-style:none" />
                       <f:param name="id" id="id" value="#{row.id}" />
                    </tr:commandLink>
                    <tr:spacer width="10" height="1"/>
                    <tr:commandLink id="deleteAction" actionListener="#{individualController.delete}" partialSubmit="true" immediate="true">
                        <tr:image source="/images/tableDelete.gif" shortDesc="#{messages['action.delete']}" inlineStyle="border-style:none" />
                        <f:param name="id" id="id" value="#{row.id}" />
                    </tr:commandLink>
                </h:panelGroup>
            </tr:column>
            <tr:column sortable="true" sortProperty="individualId">
                <f:facet name="header">
                    <tr:outputText value="#{messages['individual.individual.id']}"/>
                </f:facet>
                <tr:outputText value="#{row.individualId}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="idNumber">
                <f:facet name="header">
                    <tr:outputText value="#{messages['individual.id.number']}"/>
                </f:facet>
                <tr:outputText value="#{row.idNumber}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="salutation">
                <f:facet name="header">
                    <tr:outputText value="#{messages['individual.salutation']}"/>
                </f:facet>
                <tr:outputText value="#{ajsfc:getEnumMessage('salutation.',row.salutation)}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="surname">
                <f:facet name="header">
                    <tr:outputText value="#{messages['individual.surname']}"/>
                </f:facet>
                <tr:outputText value="#{row.surname}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="firstName">
                <f:facet name="header">
                    <tr:outputText value="#{messages['individual.first.name']}"/>
                </f:facet>
                <tr:outputText value="#{row.firstName}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="middleNames">
                <f:facet name="header">
                    <tr:outputText value="#{messages['individual.middle.names']}"/>
                </f:facet>
                <tr:outputText value="#{row.middleNames}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="sex">
                <f:facet name="header">
                    <tr:outputText value="#{messages['individual.sex']}"/>
                </f:facet>
                <tr:outputText value="#{ajsfc:getEnumMessage('gender.',row.sex)}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="postalAddress">
                <f:facet name="header">
                    <tr:outputText value="#{messages['individual.postal.address']}"/>
                </f:facet>
                <tr:outputText value="#{row.postalAddress}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="physicalAddress">
                <f:facet name="header">
                    <tr:outputText value="#{messages['individual.physical.address']}"/>
                </f:facet>
                <tr:outputText value="#{row.physicalAddress}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="email">
                <f:facet name="header">
                    <tr:outputText value="#{messages['individual.email']}"/>
                </f:facet>
                <tr:outputText value="#{row.email}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="dob">
                <f:facet name="header">
                    <tr:outputText value="#{messages['individual.dob']}"/>
                </f:facet>
                <tr:outputText value="#{row.dob}">
                    <f:convertDateTime pattern="MM/dd/yyyy"/>
                </tr:outputText>
            </tr:column>
            <tr:column sortable="true" sortProperty="idType">
                <f:facet name="header">
                    <tr:outputText value="#{messages['individual.id.type']}"/>
                </f:facet>
                <tr:outputText value="#{ajsfc:getEnumMessage('idtype.',row.idType)}">
                </tr:outputText>
            </tr:column>
            <tr:column sortable="false">
                <f:facet name="header">
                    <tr:outputText value="#{messages['location.view.title']}"/>
                </f:facet>
                <tr:outputText value="#{row.countryOfBirth}" converter="com.systemsjr.jrbase.location.crud.LocationJsfConverter"/>
            </tr:column>
            <tr:column sortable="false">
                <f:facet name="header">
                    <tr:outputText value="#{messages['location.view.title']}"/>
                </f:facet>
                <tr:outputText value="#{row.countryOfCitizenship}" converter="com.systemsjr.jrbase.location.crud.LocationJsfConverter"/>
            </tr:column>
        </tr:table>
        </tr:subform>
        </tr:panelGroupLayout>
        <tr:panelGroupLayout layout="vertical" inlineStyle="display:#{manageIndividualForm.editState?'':'none'}">
        <tr:subform id="manageIndividualForm_edit" >
            <tr:panelFormLayout>
        <tr:inputText id="individualId" value="#{manageIndividualForm.individualId}" label="#{messages['individual.individual.id']}:" required="true" readOnly="false">
        </tr:inputText>
        <tr:inputText id="idNumber" value="#{manageIndividualForm.idNumber}" label="#{messages['individual.id.number']}:" required="true" readOnly="false">
        </tr:inputText>
            <tr:selectOneChoice id="salutation" value="#{manageIndividualForm.salutation}" label="#{messages['individual.salutation']}:" required="true" readOnly="false" unselectedLabel="">
                <f:converter converterId="com.systemsjr.jrbase.individual.Salutation"/>
                <f:selectItems value="#{ajsfc:getEnumSelectItems('salutation.','com.systemsjr.jrbase.individual.Salutation')}"/>
            </tr:selectOneChoice>
        <tr:inputText id="surname" value="#{manageIndividualForm.surname}" label="#{messages['individual.surname']}:" required="true" readOnly="false">
        </tr:inputText>
        <tr:inputText id="firstName" value="#{manageIndividualForm.firstName}" label="#{messages['individual.first.name']}:" required="true" readOnly="false">
        </tr:inputText>
        <tr:inputText id="middleNames" value="#{manageIndividualForm.middleNames}" label="#{messages['individual.middle.names']}:" required="false" readOnly="false">
        </tr:inputText>
            <tr:selectOneChoice id="sex" value="#{manageIndividualForm.sex}" label="#{messages['individual.sex']}:" required="true" readOnly="false" unselectedLabel="">
                <f:converter converterId="com.systemsjr.jrbase.individual.Gender"/>
                <f:selectItems value="#{ajsfc:getEnumSelectItems('gender.','com.systemsjr.jrbase.individual.Gender')}"/>
            </tr:selectOneChoice>
        <tr:inputText id="postalAddress" value="#{manageIndividualForm.postalAddress}" label="#{messages['individual.postal.address']}:" required="true" readOnly="false">
        </tr:inputText>
        <tr:inputText id="physicalAddress" value="#{manageIndividualForm.physicalAddress}" label="#{messages['individual.physical.address']}:" required="true" readOnly="false">
        </tr:inputText>
        <tr:inputText id="email" value="#{manageIndividualForm.email}" label="#{messages['individual.email']}:" required="false" readOnly="false">
        </tr:inputText>
        <tr:inputDate id="dob" value="#{manageIndividualForm.dob}" label="#{messages['individual.dob']}:" required="true">
            <f:convertDateTime pattern="MM/dd/yyyy"/>
        </tr:inputDate>
            <tr:selectOneChoice id="idType" value="#{manageIndividualForm.idType}" label="#{messages['individual.id.type']}:" required="true" readOnly="false" unselectedLabel="">
                <f:converter converterId="com.systemsjr.jrbase.individual.IDType"/>
                <f:selectItems value="#{ajsfc:getEnumSelectItems('idtype.','com.systemsjr.jrbase.individual.IDType')}"/>
            </tr:selectOneChoice>
            <tr:inputHidden id="id" value="#{manageIndividualForm.id}"/>
            <tr:selectOneChoice id="countryOfBirth" value="#{manageIndividualForm.countryOfBirth}" label="#{messages['individual.country.of.birth']}:" required="false" readOnly="false" unselectedLabel="">
                   <c:if test="${!empty manageIndividualForm.countryOfBirthBackingList}">
                       <c:forEach var="row" items="#{manageIndividualForm.countryOfBirthBackingList}">
                           <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                       </c:forEach>
                   </c:if>
            </tr:selectOneChoice>
            <tr:selectOneChoice id="countryOfCitizenship" value="#{manageIndividualForm.countryOfCitizenship}" label="#{messages['individual.country.of.citizenship']}:" required="false" readOnly="false" unselectedLabel="">
                   <c:if test="${!empty manageIndividualForm.countryOfCitizenshipBackingList}">
                       <c:forEach var="row" items="#{manageIndividualForm.countryOfCitizenshipBackingList}">
                           <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                       </c:forEach>
                   </c:if>
            </tr:selectOneChoice>
            <tr:selectManyListbox id="nextOfKins" value="#{manageIndividualForm.nextOfKins}" label="#{messages['individual.next.of.kins']}:" required="false" readOnly="false" size="3">
                   <c:if test="${!empty manageIndividualForm.nextOfKinsBackingList}">
                       <c:forEach var="row" items="#{manageIndividualForm.nextOfKinsBackingList}">
                           <f:selectItem itemLabel="#{row[1]}" itemValue="#{row[0]}" />
                       </c:forEach>
                   </c:if>
            </tr:selectManyListbox>

            <f:facet name="footer">
                   <tr:panelButtonBar>
                       <tr:commandButton id="saveAction" text="#{messages['action.save']}" action="#{individualController.save}" accessKey="#{messages['action.save.access.key']}" partialSubmit="false"/>
                       <tr:commandButton id="saveAndNewAction" text="#{messages['action.saveAndNew']}" action="#{individualController.saveAndNew}" accessKey="#{messages['action.saveAndNew.access.key']}" inlineStyle="display:#{(empty manageIndividualForm.id)?'':'none'}" partialSubmit="false"/>
                       <tr:commandButton id="cancelAction" text="#{messages['action.cancel']}" action="#{individualController.cancel}" accessKey="#{messages['action.cancel.access.key']}" immediate="true" partialSubmit="true" />
                   </tr:panelButtonBar>
            </f:facet>
            </tr:panelFormLayout>
        </tr:subform>
        </tr:panelGroupLayout>
    </ui:define>
</ui:composition>

</html>
